package com.zb.designmode;

import java.util.Arrays;
import java.util.List;

/**
 * <p>文件描述：</p>
 * <p>版权所有： 版权所有(C)2016-2099</p>
 * <p>内容摘要： </p>
 * <p>其他说明： </p>
 * Date 2019-05-18</p>
 * Author Bing.Zhao1
 *
 * @version 1.0
 */
public class LambdaStudy {
    public static void main(String[] args) {
        traversList();
    }

    private static void traversList() {
        String[] atp = {"Rafael Nadal", "Novak Djokovic",
                "Stanislas Wawrinka",
                "David Ferrer", "Roger Federer",
                "Andy Murray", "Tomas Berdych",
                "Juan Martin Del Potro"};
        List<String> players = Arrays.asList(atp);

        // 以前的循环方式
        for (String player : players) {
            System.out.print(player + "; ");
        }
        System.out.println();

        // 使用 lambda 表达式以及函数操作(functional operation)
        players.forEach((player) -> System.out.print(player + "; "));
        System.out.println();

        // 在 Java 8 中使用双冒号操作符(double colon operator)
        players.forEach(System.out::print);
    }

}
